using System;
using UnityEngine;

[Serializable]
public class FPSCounter : MonoBehaviour
{
	public float updateInterval;

	private float accum;

	private int frames;

	private float timeleft;

	public GUIText gui;

	public FPSCounter()
	{
		updateInterval = 0.5f;
	}

	public void Start()
	{
		if (PlayerPrefs.GetInt("FPS") == 0)
		{
			Invoke("destroy", 0.4f);
		}
		gui = gameObject.GetComponent<GUIText>();
		timeleft = updateInterval;
	}

	public void destroy()
	{
		UnityEngine.Object.Destroy(gameObject);
	}

	public void Update()
	{
		timeleft -= Time.deltaTime;
		accum += Time.timeScale / Time.deltaTime;
		frames++;
		if (!(timeleft > 0f))
		{
			gui.text = string.Empty + (accum / (float)frames).ToString("f0");
			timeleft = updateInterval;
			accum = 0f;
			frames = 0;
		}
	}

	public void Main()
	{
	}
}
